﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>声明式验证</title>
</head>
<body>
    <form id="registerForm">
        <fieldset>
            <legend>用户注册信息</legend>
            <p>
                <label for="username">姓名</label>
                <input id="username" name="username" placeholder="必填" type="text" required />
            </p>
            <p>
                <label for="pwd">密码</label>
                <input id="pwd" name="pwd" placeholder="必填，至少6个字符" type="password" 
                       required minlength="6"/>
            </p>
            <p>
                <label for="confirm">确认密码</label>
                <input id="confirm" name="confirm" type="password"
                       required equalto="#pwd" />
            </p>
            <p>
                <label for="email">电子邮件</label>
                <input id="email" type="email" name="email" placeholder="必填" required />
            </p>
            <p>
                <label for="age">年龄</label>
                <input id="age" name="age" type="digits" placeholder="必填,1~100之间" 
                       required range="1,100"/>
            </p>
            <p>
                <input class="submit" type="submit" value="Submit" onclick="return register();" />
            </p>
        </fieldset>
    </form>

    <script src="scripts/jquery-1.10.2.min.js"></script>
    <script src="scripts/jquery.validate.min.js"></script>
    <script type="text/javascript">
        function register() {
            if($("#registerForm").valid()){
                return true;
            }
            return false;
        }
    </script>
</body>
</html>
